<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/vue-2.4.0.js"></script>
</head>

<body>
    <div id="app">
        <p>{{msg | msgFormat('33') | test}}</p>
    </div>

    <script>
        //定义一个vue全局的过滤器，名称叫，msgFormat
        Vue.filter('msgFormat', function (msg, arg) {
            // 字符串的 replace 方法，第一个参数，除了可写一个字符串外，还可以定义一个正则
            return msg.replace(/aaa/g, arg)
        })

        Vue.filter('test', function (msg) {
            return msg + '===='
        })
        //创建Vue实例,得到 ViewModel
        var vm = new Vue({
            el: '#app',
            data: {
                msg: 'aaabbbbaaaabbbbwwwaall'
            },
            methods: {}
        });
    </script>
</body>

</html>